package com.evan.wj.service;

import com.evan.wj.dao.NodeDao;
import com.evan.wj.pojo.Node;
import com.evan.wj.pojo.ViewNode;
import com.evan.wj.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
public class NodeService {
    @Autowired
    NodeDao nodeDao;

    public List<ViewNode> list(){
        return nodeDao.findAllViewNode();
    }

    public Node save(Node node){
        node.setTime(new Timestamp(System.currentTimeMillis()));
        Node save = nodeDao.save(node);
        return save;
    }

    public List<ViewNode> myNode(Integer userId){
        return nodeDao.findPersonalViewNode(userId);
    }

    public List<ViewNode> myNode(Integer userId,Integer cid){
        return nodeDao.findPersonalViewNode(userId,cid);
    }

    public void delete(Integer id){
        nodeDao.deleteById(id);
    }
}
